
<?php 
header("Content-Type:text/html;charset=utf-8");
include "../inc/page.class.php";
include_once '../inc/conn.php';
require '../inc/checkdate.php';
date_default_timezone_set('PRC');

?>
<html>
<head>

<title>userinfo</title>



<link href="../css/css.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript">

</script>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
</head>
<SCRIPT language=JavaScript src="../js/select_task.js"></script>
<script language="JavaScript" src ="../js/select_date.js" type="text/javascript">
</script>
</head>

<body>
<form name="fom1" id="fom1" method="post" action="">

<img src="../images/ico07.gif" width="20" height="18" />　
		 
<td width="538">查看内容：按时间：
<input name="start_time" type="text" style="border:1px solid #999;" onclick="fPopCalendar(event,this,this)" onfocus="this.select()"  />
<span class="newfont06">至</span>
<input name="stop_time" type="text" style="border:1px solid #999;" onclick="fPopCalendar(event,this,this)" onfocus="this.select()"  />
<input name="search" type="submit" class="right-button02" value="查 询" /></td>
			
</form>

<?php 
/* 定义一个显示用户信息的方法 */
$query_str="select * from task";
$result_all=$oa->query($query_str);
$total=mysql_num_rows($result_all);
$num=10;

$page=new Page($total, $num, "&id");
$dis_page='<table><tr><td align="left" width="600">'.$page->fpage(array(0,2)).'</td><td align="right" width="500">'.$page->fpage(array(4,5,6,7,8))."</td></tr></table>";

function list_task($result,$dis_page){
	$nums=mysql_num_rows($result);
	if($nums==0)
	{
		echo "<font color=red>没有找到相关记录!</font>";
	}
	else{
			echo '<form name="fom"  id="fom" >';
			echo  '<table id="subtree1" style="DISPLAY: " width="100%" border="0" cellspacing="0" cellpadding="0">';
			echo   '    <tr>';
			echo'          <td><table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">';
			echo'       
			               <td height="20"><span class="newfont07">选择：<a href="#" class="right-font08" onclick="selectAll();">全选</a>-<a href="#" class="right-font08" onclick="unselectAll();">反选</a></span>
	              <input name="Submit" type="button" class="right-button08" value="删除所选任务" onclick="del_task()"/>
	              <input name="Submit2" type="button" class="right-button08" onclick="link();" value="添加任务"/></td>
       	    </tr>
              <tr>
                <td  class="font42">
				<table width="100%" border="0" cellpadding="4" cellspacing="1" bgcolor="#464646" class="newfont03">
				 <tr class="CTitle" >
                    	<td height="22" colspan="8" align="center" style="font-size:16px" bgcolor="#EEEEEE">任务列表</td>
                  </tr>
                  <tr bgcolor="#EEEEEE">
				    <td width="6%" align="center" height="30">选择</td>
                    <td width="12%">任务标题</td>
					<td width="12%">创建时间</td>
                    <td width="12%">发送者</td>
					<td width="10%">执行人</td>
					<td width="15%">优先级</td>
					<td width="20%"><div align="center">操作</div></td>
                  </tr>';
			
				 // $result=$oa->query($result);
				   while($row=mysql_fetch_array($result))
	 		     {
				  
                  
				  echo '<tr bgcolor="#FFFFFF">';
				  echo' <td height="20">';
				  $get_id= $row['id'];
				  echo '<input type="checkbox" name="delid[]" value='.$get_id.'></td>';
                  echo '<td >'. $row['task_title'].'</td>';
				  echo '<td >'.date("Y-m-d H:i:s",$row['create_time']).'</td>';
				  
                  echo '<td>';
                  echo $row['sender'];
                  echo '</td>';
                  echo '<td>'.$row['performer'].'</td>';
                  echo '<td>';
                    switch(intval($row['task_level'])){
                    	case 1:
                    	echo "暂不需要";
                         break;
                    	case 2:
                    	echo "一般";
                    	break;
                    	case 3:
                    	echo "需要";
                    	break;
                    	case 4:
                    	echo "急";
                    	break;
                    	case 5:
                    	echo "很急";
                    	break;
                    }
        	 
					
                   echo '<td align="center"> <a href="editrenwu.php?id='.$get_id.'">编辑</a> |<a href="listrenwumingxi.php?id='.$get_id.'">查看</a>| <a href="delete_task.php?id='.$get_id.'|'.'">删除</a></td>';
                   echo '</tr>';
				  }
           echo' </table></td></tr>
        <td>'
        .$dis_page.
        '</td>
       
     
      </table>';
      echo '</form>';
	}
}
?>
<?php
//判断提交之前查询所有用户信息
	 if(empty($_POST['search'])){
     $select="select * from task  order by id desc {$page->limit}";
     $result=$oa->query( $select);
     list_task($result,$dis_page);
     
}
//提交之后查询相关信息
    if(isset($_POST['search']))
	{
		$t1 = trim(($_POST['start_time']));//开始时间取出
	    $t2  = trim($_POST['stop_time']);//结束时间取出
// 	    echo $t1;exit;
	    check_date($t1);
	    check_date($t2);
	    $start_time=intval(strtotime ($t1));
	    $stop_time=intval(strtotime($t2));
	    if ($start_time>=$stop_time)
		    {
		    	echo "<script>alert('起始与终止的时间选择不正确');</script>";
		    }
		 else
			 {
				 $key_sql="select * from task where create_time>=". $start_time." and create_time<=".$stop_time." order by id desc  {$page->limit}";
		 
	 			 $result_key=$oa->query($key_sql);
	 			 list_task($result_key,$dis_page);
			 }
	  }
	?>
</body>
</html>
